package com.ljw.security.springsecurity_springboot.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @FileName WebConfig
 * @Description TODO   相当于springMvc.xml的配置
 * @Author ljw
 * @Date 2020/9/1 14:01
 * @Version 1.0
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    //添加URL视图映射
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        //设置Url根路径跳转到/login，/login是pring Security提供的登录页面,需要重定向。
       // registry.addViewController("/").setViewName("redirect:/login");
        //redirect:/logout :  spring Security提供的退出登录页面
        //registry.addViewController("/logout").setViewName("redirect:/logout");


        //自定义登录页------根路径"/"映射到webapp/WEB-INF/view/login.jsp
        registry.addViewController("/").setViewName("redirect:/login-view");
        registry.addViewController("/login-view").setViewName("login");
        //registry.addViewController("/").setViewName("login");


    }

}
